def take(n,i):
    if -i > len(str(n)):
        return 0
    else:
        return int(str(n)[-i])

def bucket_sort(array):
    n=len(str(max(array)))
    buckets=[]
    for i in range(10):
        buckets.append([])
    rounds=1
    while rounds <= n:
        for number in array:
            value=take(number,rounds)
            buckets[value].append(number)
        i=0
        for bucket in buckets:
            while bucket:
                array[i]=bucket.pop(0)
                i+=1
        rounds+=1

sequence=[12,27,46,16,25,37,22,29,15,47,48,34]
print(sequence)
print(sorted(sequence))
bucket_sort(sequence)
print(sequence)
